package com.gnerv.sylvanas.module.redis.autoconfigure;

import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.autoconfigure.AutoConfiguration;
import org.springframework.boot.autoconfigure.ImportAutoConfiguration;
import org.springframework.boot.autoconfigure.data.redis.RedisAutoConfiguration;
import org.springframework.boot.context.properties.EnableConfigurationProperties;

import java.util.Map;

/**
 * @author Gnerv LiGen
 */
@Slf4j
@AutoConfiguration
@EnableConfigurationProperties(DynamicRedisDataSourceProperties.class)
@ImportAutoConfiguration(classes = {RedisAutoConfiguration.class})
public class DynamicRedisDataSourceAutoConfiguration {

    public DynamicRedisDataSourceAutoConfiguration(DynamicRedisDataSourceProperties dynamicRedisDataSourceProperties) {
        Map<String, RedisDataSourceProperties> redis = dynamicRedisDataSourceProperties.getRedis();
        for (Map.Entry<String, RedisDataSourceProperties> stringRedisDataSourcePropertiesEntry : redis.entrySet()) {
            RedisDataSourceProperties redisDataSourceProperties = stringRedisDataSourcePropertiesEntry.getValue();
            new LettuceConnectionConfiguration(redisDataSourceProperties, null, null, null);
        }

    }

}
